<template>
  <div class="container" @click="handleGallaryClick">
    <div class="wrapper">
      <swiper :options="swiperOption">
        <!-- 实现循环渲染轮播图 -->
        <swiper-slide v-for="item in imgList" :key="item">
          <img :src="item" alt="">
        </swiper-slide>

        <div class="swiper-pagination"  slot="pagination"></div>

      </swiper>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CommonGallary',
  props: {
    imgList: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        paginationType: 'fraction',
        //  修正进入 Gallary swiper 未更新问题
        observer: true,
        observeParents: true
      }
    }
  },
  methods: {
    handleGallaryClick () {
      this.$emit('close')
    }
  }
}
</script>

<style scoped lang="less">
.container /deep/ .swiper-container{
  overflow: inherit;
}
.container{
  background-color: black;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  z-index: 2;
  .wrapper{
    width: 100%;
    /* 防抖动 */
    img{
      width: 100%;
    }
    .swiper-pagination{
      position: fixed;
      color: white;
      bottom: 1.5rem;
    }
  }
}
</style>
